package com.aya.transaction;

import com.aya.transaction.mapper.BlogMapper;
import com.aya.transaction.service.BlogNoTransactionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * 非事物不回滚
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringTransaction.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class NoTransaction {

    @Resource
    BlogNoTransactionService blogNoTransactionService;
    @Test
    public void testSuccess(){
        blogNoTransactionService.updateById("1","transaction success");
    }

    @Test
    public void testFailure(){
        blogNoTransactionService.updateByIdWithException("1","transaction failure");
    }
}
